package com.hs.room.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.hs.room.model.sys.SysLog
import kotlinx.coroutines.flow.Flow

@Dao
interface SysLogDao {

    @Insert
    fun insertSysLog(sysLog: SysLog)

    @Update
    fun updateSysLog(sysLog: SysLog): Int

    @Query("SELECT * FROM sys_log")
    fun getSysLogs(): Flow<List<SysLog>>

    @Query("SELECT count(*) FROM sys_log")
    fun count(): Int

    /**
     * 条件查询
     */
    @Query("SELECT * FROM sys_log LIMIT :pageSize OFFSET  ((:pageIndex - 1) * :pageSize)")
    fun getByCombinedConditions( pageIndex: Int,
                                             pageSize: Int) :
           Flow<List<SysLog>>


     @Query("SELECT COUNT(1) FROM sys_log ")
     fun getAllCountByCombinedConditions(): Int


}